# Maintainer: Konstantin Gizdov <arch at kge dot pw>
# Contributor: Eric Förster <eric DOT foerster AT outlook DOT com>
# Contributor: Patrick Förster <patrick DOT foerster AT outlook DOT de>

pkgname=texlab
pkgver=5.6.0
pkgrel=1
pkgdesc="A cross-platform implementation of the Language Server Protocol for LaTeX."
arch=('loong64' 'x86_64')
url="https://texlab.netlify.com"
license=('MIT')
depends=('gcc-libs')
makedepends=('cargo' 'npm')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/latex-lsp/texlab/archive/v${pkgver}.tar.gz")
b2sums=('3dbda31309a6f749f46a32fecf1df814236a0ffc05ced70e0cc9a04fd1a3eef136acb8e40128c37a357767dc16afe4e3c0e8e6e3ffff39a3a615639db3677069')
options=('!lto')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  export RUSTUP_TOOLCHAIN=stable
  export CARGO_TARGET_DIR=target
  cargo build --frozen --release --all-features
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  export RUSTUP_TOOLCHAIN=stable
  cargo test --frozen --all-features
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  install -Dm 755 "target/release/${pkgname}" "${pkgdir}/usr/bin/${pkgname}"
  install -Dm 644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
